home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nebula 2
/
Nebula Two.iso
/
WebObjects
/
SourceCode
/
Create-A-Card
/
Main.wo
/
Main.wos
< prev
Wrap
Text File
|
1996-01-25
|
2KB
|
79 lines
/*
* Main.wos
* You may freely copy, distribute, and reuse the code in this example.
* NeXT disclaims any warranty of any kind, expressed or implied, as to its
* fitness for any particular use.
*
* Written by Katie McCormick
*
*/
id nameString;
id ageString;
id messageString;
- awake {
if(!messageString)
messageString = @"Type your birthday message here.";
}
- happyBirthday
{
id nextPage, nameDict, suffix, age, result;
//
// Create a dictionary to hold the name of the current recipient
//
nameDict = [NSMutableDictionary dictionary];
//
// Put the current recipient in the dictionary
//
[nameDict setObject:nameString forKey:@"aName"];
//
// Add the dictionary containing the recipient's name to the global
// variable namesArray. This array maintains a list of all recipients
// across all sessions. When a user clicks the 'Show all recipients'
// button, namesArray is iterated to display all recipient names.
//
[[WOApp namesArray] addObject:nameDict];
//
// Figure out the right suffix to append to the recipient's age
//
age = [ageString intValue];
result = age % 10;
if(result == 1 && age !=11)
suffix = @"st";
else if (result == 2 && age != 12)
suffix = @"nd";
else if (result == 3 && age != 13)
suffix = @"rd";
else
suffix = @"th";
//
// Set the values of variables declared in the page "HappyBirthday"
//
nextPage = [WOApp pageWithName:@"HappyBirthday"];
[nextPage setNameString:nameString];
[nextPage setAgeSuffix:suffix];
[nextPage setAgeString:ageString];
//
// If the user didn't type a message, set messageString to be an empty
// string.
//
if ([messageString isEqualToString:@"Type your birthday message here."])
messageString = @"";
[nextPage setMessageString:messageString];
return nextPage;
}
//
// Show all of the recipients, across all sessions
//
- showRecipients
{
id nextPage;
nextPage = [WOApp pageWithName:@"Recipients"];
return nextPage;
}